module.exports = {
	prefix: "/bus/extend/lottery",
	get: {
		"/with_winner_list_info/by_id/:lottery_id": function() {
			var lottery_id = this.params.lottery_id;
			var query = this.request.query;
			var bus = role.getBus(this);

			this.body = ResponObj("json", bus.getLotteryWidthWinnerListInfo(lottery_id, query.is_with_visitor_map))
		},
	},
	post: {
		"/add_lottery": function() {
			var bus = role.getBus(this);
			var body = this.request.body;
			var lottery = bus.addLottery(body);

			if (body.return_type === "lottery_list") {
				this.body = ResponObj("json", bus.getLotteryList(body.is_with_visitor_map));
			} else {
				this.body = ResponObj("json", bus.getLottery(lottery._id, body.is_with_visitor_map));
			}
		}
	},
	put: {
		"/update_lottery/:lottery_id": function() {
			var bus = role.getBus(this);
			var lottery_id = this.params.lottery_id;
			var body = this.request.body;
			bus.updateLottery(lottery_id, body);

			if (body.return_type === "lottery_list") {
				this.body = ResponObj("json", bus.getLotteryList(body.is_with_visitor_map));
			} else {
				this.body = ResponObj("json", bus.getLottery(lottery_id, body.is_with_visitor_map));
			}
		}
	},
	"delete": {
		"/remove_lottery/:lottery_id": function() {
			var bus = role.getBus(this);
			var lottery_id = this.params.lottery_id;
			var body = this.request.body;
			bus.removeLottery(lottery_id);
			this.body = ResponObj("json", bus.getLotteryList(body.is_with_visitor_map));
		}
	}
}
var role = require("./role");
var BusCon = require("../../core/bus/_con");
var UserCon = require("../../core/user/_con");
var GoodsCon = require("../../core/goods/_con");
var AchCon = require("../../core/ach/_con");
var db = require("../../core/db/index");
var config = require("../../core/_include/config");
var ResponObj = require("../_include/responObj");